#!/usr/bin/python3
# -*- coding: utf-8 -*-

from playwright.sync_api import Page

from utils.log import log


class Message:
    def __init__(self, page: Page):
        self.page = page

    def wait_message(self):
        """
        获取消息弹框
        :return:
        """
        if self.page.wait_for_selector(".portal-ui-notify", state="visible").is_visible():
            log.info(f"==========页面弹出:【portal-ui】消息框组件 ==========")
            action = self.page.wait_for_selector(".css-irflhw", state="visible")
            if action.is_visible():
                log.info(f"动作:{action.text_content()}")
            resource_type = self.page.wait_for_selector(".css-1blen2r", state="visible")
            if resource_type.is_visible():
                log.info(f"资源类型:{resource_type.text_content()}")
            resouce_id = self.page.wait_for_selector(".css-1ew0cqk", state="visible")
            if resouce_id.is_visible():
                log.info(f"资源ID:{resouce_id.text_content()}")
            job_time = self.page.wait_for_selector(".css-lu3mdg", state="visible")
            if job_time.is_visible():
                log.info(f"时间:{job_time.text_content()}")
